package s63.kong.shop.modules.rabbit;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;
import s63.kong.shop.pojo.User;
import s63.kong.shop.service.UserService;

import javax.annotation.Resource;

@Slf4j
@Component
public class MqConsumer {
    @Resource
    private UserService userService;

    @RabbitListener(queues = "kong.queue.created")
    public void createQueue(User user){
        log.info("收到创建用户的消息：{}",user);
        userService.save(user);
        log.info("异步保存用户成功：{}",user);
    }
}
